package cn.lingyangwl.agile.auth.service.impl;

import cn.lingyangwl.agile.auth.model.mq.LoginLogMQ;
import cn.lingyangwl.agile.auth.service.AuthMqService;
import cn.lingyangwl.agile.model.module.mq.OAuth2ClientMQ;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author shenguangyang
 */
@Service
public class AuthMqServiceImpl implements AuthMqService {
    @Resource
    private RabbitTemplate rabbitTemplate;

    @Override
    public void send(LoginLogMQ mq) {
        rabbitTemplate.convertAndSend(LoginLogMQ.EXCHANGE, LoginLogMQ.KEY, mq.toMessage());
    }

    @Override
    public void deleteClientAuthority(String clientId) {
        rabbitTemplate.convertAndSend(OAuth2ClientMQ.EXCHANGE, "", OAuth2ClientMQ.build(clientId).toMessage());
    }
}
